package 笔试.拼多多;

import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        int[] ans = new int[T];
        for(int i=0;i<T;i++){
            int N = in.nextInt();
            int M = in.nextInt();
            boolean flag = false;
            for(int j=1;j<100;j++){
                if(countBit(M*j)==N){
                    ans[i] = M*j;
                    flag = true;
                    break;
                }
            }
            //不存在输出-1
            if(!flag){
                ans[i] = -1;
            }

        }
        for (int t : ans) {
            System.out.println(t);
        }
    }

    //判断位数
    public static int countBit(int n){
        int count = 0;
        while(n!=0){
            count++;
            n = n/10;
        }
        return count;
    }
}
